﻿using System;
using System.Collections.Generic;
using System.Text;
using AuthTemplate.DTO.User;
using AuthTemplate.Entity;
using AuthTemplate.Infrastructure;
using AuthTemplate.Infrastructure.AutoMapper;
using AuthTemplate.Infrastructure.DotNet.Utilities;
using AuthTemplate.Service;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;

namespace AuthTemplate.MVC.Tests
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            HttpHelper helper = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://localhost:64376/api/Register/getDayRegSource",
                Method = "POST",
                PostDataType = PostDataType.Byte,
                PostEncoding = Encoding.UTF8,
                Postdata = "{ \"orgCode\":\"谔谔谔谔\", \"sss\":\"sssssss\",\"depCode\":\"啊实打实\"}",
                Accept = "application/json",    //希望接受的数据类型
                ContentType = "application/json",//本次请求发送的数据的数据格式
                ResultType = ResultType.Byte
            };

            HttpResult result = helper.GetHtml(item);

            if(result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string ss = result.Html;
                //GetDayRegSourceInput resp = JsonConvert.DeserializeObject<GetDayRegSourceInput>(ss);
            }
            GetDayRegSourceInput resp = JsonConvert.DeserializeObject<GetDayRegSourceInput>(result.Html);
        }

        [TestMethod]
        public void ttt()
        {
            HttpHelper helper = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://localhost:64376/api/Register/getDayRegSource",
                Method = "POST",
                PostDataType = PostDataType.String,
                PostEncoding = Encoding.UTF8,
                Postdata = "{ \"orgCode\":\"谔谔谔谔\", \"sss\":\"sssssss\",\"depCode\":\"啊实打实\"}",
                Accept = "application/json",    //希望接受的数据类型
                ContentType = "application/json",//本次请求发送的数据的数据格式
                ResultType = ResultType.String
            };

            HttpResult result = helper.GetHtml(item);
            string ss = "";
            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                ss = result.Html;
                //GetDayRegSourceInput resp = JsonConvert.DeserializeObject<GetDayRegSourceInput>(ss);
            }

            GetDayRegSourceInput resp = JsonConvert.DeserializeObject<GetDayRegSourceInput>(ss);
        }
        public static T Deserialize<T>(string input)
        {
            return JsonConvert.DeserializeObject<T>(input);
        }

        [TestMethod]
        public void Test()
        {
            string newPassword = "111111";
            string salt = "";
            string hashPassword = HashEncode.HashSaltEncoding(newPassword, out salt);
            
        }

        [TestMethod]
        public void MapperTest()
        {
            AddUserInput input = new AddUserInput();
            input.Account = "admin";
            input.Password = "111111";
            input.Status = 1;

            MappingConfiguration.InitializeMapper();

            User user = input.Map<User>();
            user.CreateTime = DateTime.Now;
        }

        [TestMethod]
        public void t()
        {
            
        }
    }

    public class GetDayRegSourceInput
    {
        /// <summary>
        /// 医院代码
        /// </summary>
        public string orgCode { get; set; }

        /// <summary>
        /// 科室代码
        /// </summary>
        public string depCode { get; set; }

        /// <summary>
        /// 挂号类型
        /// 
        /// 见值域-挂号类型
        /// </summary>
        public string regType { get; set; }

        /// <summary>
        /// 医生工号
        /// 
        /// 非普通门诊必填
        /// </summary>
        public string docCode { get; set; }

        /// <summary>
        /// 查询日期
        /// 
        /// YYYY-MM-DD
        /// </summary>
        public string date { get; set; }

        /// <summary>
        /// 开始时间
        /// 
        /// HH:mm
        /// </summary>
        public string startTime { get; set; }

        /// <summary>
        /// 结束时间
        /// 
        /// HH:mm
        /// </summary>
        public string endTime { get; set; }
    }
}
